package nl.hanze.designpatterns.mvc.controller;

import java.awt.event.ActionEvent;

import javax.swing.JButton;

import nl.hanze.designpatterns.domain.ThesaurusItem;
import nl.hanze.designpatterns.mvc.model.ThesaurusModel;

public class ThesaurusController extends Controller<ThesaurusModel> {

	public static final String THESAURUS_SELECT = "thesaurus_item_select";
	public static final String THESAURUS_BACK = "thesaurus_back";
	
	public ThesaurusController(ThesaurusModel model) {
		super(model);
		
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		switch (e.getActionCommand()) {
		case THESAURUS_SELECT:
			JButton button = (JButton)e.getSource();
			ThesaurusItem item = (ThesaurusItem) button.getClientProperty("item");
			getModel().setCurrent(item);
			break;
		case THESAURUS_BACK:
			getModel().back();
			break;
		default:
			break;
		}
	}

}
